<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="../css/docs.css" type="text/css" rel="stylesheet" />
<link href="../css/prettify.css" type="text/css" rel="stylesheet" />
<script src="../js/prettify.js" type="text/javascript"></script>
</head>
<body onLoad="prettyPrint()">
<div class="g-unit" id="doc-content">
<div id="api-info-block">
    <div class="api-level">H3C CAS云管理平台</div>
  </div>
  <div id="jd-header">
    <h1>克隆虚拟机</h1>
  </div>
</div>
<div id="jd-content">
<div class="jd-descr">
<p>克隆指定的虚拟机</p>
<h2><a name="uri"></a>接口 URI</h2>
<p>/cas/casrs/vm/clone</p>
<h2><a name="access"></a>访问方法</h2>
<dl>
  <dt><b>HTTP 方法</b></dt>
  <dd>PUT</dd>
  <dt><b>消息体</b></dt>
  <div class="source">
  	<pre class="prettyprint lang-xml">&lt;vmCloneParameter&gt;<br>  &lt;id&gt;38&lt;/id&gt;<br>  &lt;targetHostId&gt;3&lt;/targetHostId&gt;<br>  &lt;domainName&gt;jj02-clone5&lt;/domainName&gt;<br>  &lt;title&gt;jj02-clone5&lt;/title&gt;<br>  &lt;cloneMode&gt;1&lt;/cloneMode&gt;<br>  &lt;cloneType&gt;0&lt;/cloneType&gt;<br>  &lt;diskFormat&gt;qcow2&lt;/diskFormat&gt;<br>  &lt;storage&gt;<br>    &lt;src&gt;jj02&lt;/src&gt;<br>    &lt;dest&gt;jj02-clone5&lt;/dest&gt;<br>    &lt;pool&gt;defaultpool&lt;/pool&gt;<br>  &lt;/storage&gt;<br>  &lt;network&gt;<br>    &lt;key&gt;0c:da:41:1d:5e:f2&lt;/key&gt;<br>    &lt;value&gt;3.3.3.3&lt;/value&gt;<br>  &lt;/network&gt;<br>  &lt;net&gt;<br>    &lt;mac&gt;0c:da:41:1d:59:be&lt;/mac&gt;<br>    &lt;name&gt;vswitch0&lt;/name&gt;<br>    &lt;sysIpType&gt;2&lt;/sysIpType&gt;<br>    &lt;sysIp&gt;192.168.1.185&lt;/sysIp&gt;<br>    &lt;sysGateway&gt;192.168.1.1&lt;/sysGateway&gt;<br>    &lt;sysDns&gt;2.2.2.2&lt;/sysDns&gt;<br>    &lt;secondaryDns&gt;3.3.3.3&lt;/secondaryDns&gt;<br>    &lt;sysMask&gt;255.255.255.0&lt;/sysMask&gt;<br>    &lt;isBindIp&gt;true&lt;/isBindIp&gt;<br>  &lt;/net&gt;<br>&lt;/vmCloneParameter&gt;</pre>
  </div>
</dl>

<dt><a name="detail"></a><b>元素含义</b></dt>
  <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2"><span class="prettyprint lang-xml">vmParamter</span>各子元素</th>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">id</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">需要克隆的虚拟机 ID。</span>
            <div class="jd-descrdiv">长整数（long）类型。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">targetHostId</span></td>
        <td class="jd-linkcol"><span class="sympad">目标主机ID。</span>
          <div class="jd-descrdiv">长整数（long）类型。</div></td>
      </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">domainName</span></td>
        <td class="jd-linkcol"><span class="sympad">目标虚拟机名称。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">title</span></td>
        <td class="jd-linkcol"><span class="sympad">虚拟机显示名称。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">cloneMode</span></td>
        <td class="jd-linkcol"><span class="sympad">克隆方式：枚举:0表示普通克隆，1表示快速克隆。   </span>
          <DIV></DIV>
          <div class="jd-descrdiv">枚举(enum):0，1</div></td>
	  </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">cloneType</span></td>
        <td class="jd-linkcol"><span class="sympad"> 克隆目的位置：枚举:0表示本地克隆，1表示主机间克隆。   </span>
          <div class="jd-descrdiv">枚举(enum):0，1</div></td>
	  </tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">diskFormat</span></td>
        <td class="jd-linkcol"><span class="sympad">磁盘类型，支持raw和qcow2格式，如不填写，则不修改磁盘类型。</span>
          <div class="jd-descrdiv">枚举：raw，qcow2。</div></td>
      </tr>
	  <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">storage</span></td>
        <td class="jd-linkcol">虚拟机存储列表。
          <div class="jd-descrdiv">
            <DIV>集合（List）类型。</DIV>
          </div></td></tr>
	  <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">network</span></td>
        <td class="jd-linkcol">虚拟机网卡信息列表。
          <div class="jd-descrdiv">
            <DIV>集合（List）类型。</DIV>
          </div></td></tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">net</span></td>
        <td class="jd-linkcol">OS网络信息列表（通过castools设置）。
          <div class="jd-descrdiv">
            <DIV>集合（List）类型。</DIV>
          </div></td></tr>
  </table>
  <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2"><span class="prettyprint lang-xml">storage</span>各子元素</th>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">src</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">原存储镜像文件的名称。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">dest</span></td>
        <td class="jd-linkcol"><span class="sympad">目的存储镜像文件名。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">pool</span></td>
        <td class="jd-linkcol"><span class="sympad">目的存储池。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>  
  </table>
  <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2"><span class="prettyprint lang-xml">network</span>各子元素</th>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">key</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">网卡MAC地址。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">value</span></td>
        <td class="jd-linkcol"><span class="sympad">网卡绑定的IP地址。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
  </table>
    <table id="pubmethods" class="jd-sumtable">
    <tbody>
      <tr>
        <th colspan="2"><span class="prettyprint lang-xml">net</span>各子元素</th>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">mac</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">网卡MAC地址。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr >
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">name</span></td>
        <td width="100%" class="jd-linkcol"><span class="sympad">虚拟交换机名称。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">sysIpType</span></td>
        <td class="jd-linkcol"><span class="sympad">ip分配方式 0:默认 1:DHCP 2:手动分配</span>
          <div class="jd-descrdiv">整数（Integer）类型。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">sysIp</span></td>
        <td class="jd-linkcol"><span class="sympad">ip地址。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">sysGateway</span></td>
        <td class="jd-linkcol"><span class="sympad">默认网关。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">sysDns</span></td>
        <td class="jd-linkcol"><span class="sympad">主DNS。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">secondaryDns</span></td>
        <td class="jd-linkcol"><span class="sympad">备DNS。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      <tr>
        <td class="jd-typecol"><span class="prettyprint lang-xml">sysMask</span></td>
        <td class="jd-linkcol"><span class="sympad">子网掩码。</span>
          <div class="jd-descrdiv">字符串（String）类型。</div></td>
      </tr>
      <tr class="alt-color">
        <td class="jd-typecol"><span class="prettyprint lang-xml">isBindIp</span></td>
        <td class="jd-linkcol"><span class="sympad">是否绑定ip。</span>
          <div class="jd-descrdiv">Boolean类型。</div></td>
      </tr>
  </table>
<h2><a name="result"></a>返回结果</h2>
<dl>
  <dt><b>状态码</b></dt>
  <dd>
  <ul>
    <li>200(OK)：提交删除任务成功。</li>
  </ul>
  <ul>
    <li>409(Conflict)：失败。</li>
  </ul>
  </dd>
  <dt><b>消息头</b></dt>
  <div class="source">
    <pre class="prettyprint lang-xml">HTTP/1.1 200 OK<br>Server: Apache-Coyote/1.1<br>Set-Cookie: JSESSIONID=BDF7B4EDFDBA9FBF003D195F802D705F; Path=/imcrs<br>Date: Fri, 23 Dec 2011 04:44:21 GMT
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;taskMsg&gt;<br>  &lt;msgId&gt;1393831560400&lt;/msgId&gt;<br>  &lt;completed&gt;false&lt;/completed&gt;<br>  &lt;progress&gt;0&lt;/progress&gt;<br>  &lt;eventType&gt;0&lt;/eventType&gt;<br>&lt;/taskMsg&gt;</pre>
  </div>
</dl>

    <h2><a name="example"></a>应用举例</h2>
    <p>克隆id为38的虚拟机，本主机内克隆。</p>
    <dl>
      <dt><b>请求</b></dt>
      <div class="source">
        <pre class="prettyprint lang-xml">PUT http://192.168.0.4:8080/cas/casrs/vm/clone
accept: application/xml


&lt;vmCloneParameter&gt;<br>  &lt;id&gt;38&lt;/id&gt;<br>  &lt;targetHostId&gt;3&lt;/targetHostId&gt;<br>  &lt;domainName&gt;jj02-clone5&lt;/domainName&gt;<br>  &lt;cloneMode&gt;1&lt;/cloneMode&gt;<br>  &lt;cloneType&gt;0&lt;/cloneType&gt;<br>  &lt;diskFormat&gt;qcow2&lt;/diskFormat&gt;<br>  &lt;storage&gt;<br>    &lt;src&gt;jj02&lt;/src&gt;<br>    &lt;dest&gt;jj02-clone5&lt;/dest&gt;<br>    &lt;pool&gt;defaultpool&lt;/pool&gt;<br>  &lt;/storage&gt;<br>  &lt;network&gt;<br>    &lt;key&gt;0c:da:41:1d:5e:f2&lt;/key&gt;<br>    &lt;value&gt;3.3.3.3&lt;/value&gt;<br>  &lt;/network&gt;<br>&lt;/vmCloneParameter&gt;
</pre>
      </div>
      <dt><b>回应</b></dt>
      <div class="source"><pre class="prettyprint lang-xml">HTTP/1.1 200 OK<br>Server: Apache-Coyote/1.1<br>Set-Cookie: JSESSIONID=BDF7B4EDFDBA9FBF003D195F802D705F; Path=/imcrs<br>Date: Fri, 23 Dec 2011 04:44:21 GMT
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;taskMsg&gt;<br>  &lt;msgId&gt;1393831560400&lt;/msgId&gt;<br>  &lt;completed&gt;false&lt;/completed&gt;<br>  &lt;progress&gt;0&lt;/progress&gt;<br>  &lt;eventType&gt;0&lt;/eventType&gt;<br>&lt;/taskMsg&gt;</pre>
      </div>
    </dl>
    
        <p>克隆id为38的虚拟机，本主机内克隆，通过castools设置ip。</p>
    <dl>
      <dt><b>请求</b></dt>
      <div class="source">
        <pre class="prettyprint lang-xml">PUT http://192.168.0.4:8080/cas/casrs/vm/clone
accept: application/xml


&lt;vmCloneParameter&gt;<br>  &lt;id&gt;38&lt;/id&gt;<br>  &lt;targetHostId&gt;3&lt;/targetHostId&gt;<br>  &lt;domainName&gt;jj02-clone5&lt;/domainName&gt;<br>  &lt;cloneMode&gt;1&lt;/cloneMode&gt;<br>  &lt;cloneType&gt;0&lt;/cloneType&gt;<br>  &lt;diskFormat&gt;qcow2&lt;/diskFormat&gt;<br>  &lt;storage&gt;<br>    &lt;src&gt;jj02&lt;/src&gt;<br>    &lt;dest&gt;jj02-clone5&lt;/dest&gt;<br>    &lt;pool&gt;defaultpool&lt;/pool&gt;<br>  &lt;/storage&gt;<br>  &lt;net&gt;<br>    &lt;mac&gt;0c:da:41:1d:59:be&lt;/mac&gt;<br>    &lt;name&gt;vswitch0&lt;/name&gt;<br>    &lt;sysIpType&gt;2&lt;/sysIpType&gt;<br>    &lt;sysIp&gt;192.168.1.185&lt;/sysIp&gt;<br>    &lt;sysGateway&gt;192.168.1.1&lt;/sysGateway&gt;<br>    &lt;sysDns&gt;2.2.2.2&lt;/sysDns&gt;<br>    &lt;secondaryDns&gt;3.3.3.3&lt;/secondaryDns&gt;<br>    &lt;sysMask&gt;255.255.255.0&lt;/sysMask&gt;<br>    &lt;isBindIp&gt;true&lt;/isBindIp&gt;<br>  &lt;/net&gt;<br>&lt;/vmCloneParameter&gt;
</pre>
      </div>
      <dt><b>回应</b></dt>
      <div class="source"><pre class="prettyprint lang-xml">HTTP/1.1 200 OK<br>Server: Apache-Coyote/1.1<br>Set-Cookie: JSESSIONID=BDF7B4EDFDBA9FBF003D195F802D705F; Path=/imcrs<br>Date: Fri, 23 Dec 2011 04:44:21 GMT
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;taskMsg&gt;<br>  &lt;msgId&gt;1393831560400&lt;/msgId&gt;<br>  &lt;completed&gt;false&lt;/completed&gt;<br>  &lt;progress&gt;0&lt;/progress&gt;<br>  &lt;eventType&gt;0&lt;/eventType&gt;<br>&lt;/taskMsg&gt;</pre>
      </div>
    </dl>
</div>
</div>
</div>
</body>
</html>